Ext.define('AmpleHarvest.objects.groups.forms.cMember',
{
	extend			: 'Ext.form.Panel',
	alias			: 'widget.ampleharvest-objects-groups-forms-cmember',
	requires		:
	[
			"Ext.form.field.Hidden", "Ext.form.field.Text",
			"Ext.form.field.Checkbox", "Ext.form.field.TextArea",
			"Ext.form.field.ComboBox"
	],
	labelWidth		: 93,
	buttonAlign		: 'right',
	frame			: true,
	timeout			: 1000,
	bodyStyle		: 'padding:5px 5px 0',
	standardSubmit	: false,
	defaultType		: 'textfield',

	initComponent	: function()
	{
		var obj_This = this;
		var obj_members = Ext.ComponentQuery.query('ampleharvest-objects-groups-window-cgroupmembers',  m_obj_AmpleHarvest_ViewPort);
		this.m_str_RequestID = obj_members.m_str_RequestID;
		this.buttons =
		[
				{
					text		: 'Cancel',
					disabled	: false,
					handler		: function()
					{
						obj_This.ownerCt.destroy();
					}
				},
				{
					text		: 'Add',
					formBind	: true,
					disabled	: true,
					scope		: this,
					handler		: function()
					{

						obj_This.getForm().submit(
						{
							url		: m_obj_AmpleHarvest_ViewPort.configObject.C_STR_EXTERNAL_PATH+'/rest/group/member.php',
							waitMsg	: 'Submiting Your Group Request',
							method	: "put",
							success	: this.submit_Success,
							failure	: this.submit_Fail,
							scope	: this
						}
						);
					}
				}
		];

		this.callParent();
		this.m_str_UserName = obj_config.user.userName;

		this.add(Ext.create("Ext.form.field.Hidden",
		{
			name		: "groupId",
			value		: this.m_str_RequestID
		}
		));
		
		this.add(Ext.create("Ext.form.field.Hidden",
		{
			name		: "admin",
			value		: '0'
		}
		));
		
		this.add(Ext.create("Ext.form.field.Text",
		{
			fieldLabel	: "Member SID",
			name		: "sid",
			inputType	: "textfield",
			readOnly	: false,
			anchor		: '100%',
			allowBlank	: false
		}
		));

	},

	submit_Success	: function(str_Function, mix_Arg)
	{	
		this.ownerCt.obj_member_panel.load_store();
		this.ownerCt.close();
		Ext.MessageBox.alert("Success", "Your Request has been sent.", close);
	},

	submit_Fail		: function(str_Function, mix_Arg)
	{
		Ext.MessageBox.alert("Error", mix_Arg.result.errors.msg, close);
	}
}
);
